package site.wtcc.originalfavor.dao.plugin;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;

import java.time.LocalDateTime;

@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("start insert fill ....");
        this.setFieldValByName("createTime", LocalDateTime.now(), metaObject);
        this.setFieldValByName("modifyTime", LocalDateTime.now(), metaObject);
        this.setFieldValByName("gmt_create", LocalDateTime.now(), metaObject);
        this.setFieldValByName("gmt_modified", LocalDateTime.now(), metaObject);
        this.setFieldValByName("version", 1L, metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("start update fill ....");
        this.setFieldValByName("modifyTime", LocalDateTime.now(), metaObject);
        this.setFieldValByName("gmt_modified", LocalDateTime.now(), metaObject);
    }
}

